<template>
  <view class="content">
    <!-- #ifdef MP-TOUTIAO -->
      <Search />
      <Recommend />
      <image
      class="bg"
      :src="EnumBG.INDEXBG"
    ></image>
    <!-- #endif -->

   <!-- #ifdef H5 -->
    <IndexHeder />
    <IndexBody ref="indexBody" />
   <!-- #endif -->

  </view>
  <Recommends :top='100' />
</template>
<script setup lang="ts">
// #ifdef MP-TOUTIAO
import Search from "./components/Search.vue";
import Recommend from "./components/Recommend.vue";
import Recommends from "@/components/Recommend/Recommend.vue";
import { EnumBG } from "@/utils/content";
import { adPopAPI } from "@/utils/ab";

const  ad = ref()
onShareAppMessage((shareOption)=> {
    return {
      channel: "video",
      title: "潮象潮玩",
      success: () => {
        console.log("分享成功");
      },
    };
  },)
  const startTimer = () => {
    setInterval(() => {
        adPopAPI(ad)
      ad && ad.value.show();
    }, 60000); // 40秒执行一次
};

// #endif

// #ifdef H5
import IndexHeder from "./components/H5/IndexHeder.vue";
import IndexBody from "./components/H5/IndexBody.vue";

const indexBody = ref()


// 下拉刷新
onReachBottom(()=>{
  indexBody.value.getList()
})


// #endif
onLoad(async()=>{
  // #ifdef MP-TOUTIAO

//   tt.login({
//   force: true,
//   success(res) {
//     console.log(`login 调用成功${res.code} ${res.anonymousCode}`);
//   },
//   fail(res) {
//     console.log(`login 调用失败`);
//   },
// });
  startTimer();
  // #endif
})

</script>
<style>
page {
  width: 100%;
  height: 100%;
}
</style>
<style lang="scss" scoped>
.content {
  width: 100%;
  height: 100%;
  position: 20rpx;
  .bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw; /* 视口宽度 */
    height: 100vh; /* 视口高度 */
    z-index: -1;
    } 
}

</style>